package com.myk.game.shapechesstool.dialogs;

import android.content.Context;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.view.Window;
import android.widget.EditText;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatDialog;

import com.myk.game.shapechesstool.R;

public class SettingDialog extends AppCompatDialog {

    public SettingDialog(@NonNull Context context) {
        super(context);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setCanceledOnTouchOutside(true);
        setContentView(R.layout.dialog_setting);
        TextWatcher textWatcher = new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {

            }

            @Override
            public void afterTextChanged(Editable s) {
                String text = s.toString().trim();
                if (text.equals("0")||text.equals("")){
                    s.clear();
                    s.append("1");
                }
            }
        };
        EditText  edt_board_col = findViewById(R.id.edt_board_col);
        edt_board_col.addTextChangedListener(textWatcher);
        EditText  edt_board_row = findViewById(R.id.edt_board_row);
        edt_board_row.addTextChangedListener(textWatcher);
        EditText  edt_max_score = findViewById(R.id.edt_max_score);
        edt_max_score.addTextChangedListener(textWatcher);
    }
}
